﻿using EMS.system.IEntityAppService.MasterData.LvnventoryOnhandService;
using EMS.system.IEntityAppService.MasterData.LvnventoryOnhandService.LvnventoryOnhandDTO;
using Microsoft.AspNetCore.Mvc;
using ServiceStack;
using System.Collections.Generic;
using System.Linq.Dynamic.Core;
using System.Threading.Tasks;

namespace EMS.system.Web.Controllers.MasterData.LvnventoryOnhands
{
    public class LvnventoryOnhandController : Controller
    {
        private readonly ILvnventoryOnhandAppService _lvnventoryOnhandAppService;
        public LvnventoryOnhandController(ILvnventoryOnhandAppService lvnventoryOnhandAppService)
        {
            _lvnventoryOnhandAppService = lvnventoryOnhandAppService;
        }

        public IActionResult LvnventoryOnhandList()
        {
            return View();
        }
        /// <summary>
        /// 获取物料类型列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<MaterialTypeTreeDTO>> GetMaterialTypeTree()
        {
            return await _lvnventoryOnhandAppService.GetMaterialTypeTree();
        }
        /// <summary>
        /// 获取库存现有量显示 分页 查询
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="materialCode"></param>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<JsonResult> GetLvnventoryOnhandList(int page, int limit, string? materialCode, string? warehouse)
        {
            var lvnventoryOnhand= await _lvnventoryOnhandAppService.GetLvnventoryOnhandList(page, limit, materialCode, warehouse);
            return Json(new { code = 0,data=lvnventoryOnhand.Queryable,count=lvnventoryOnhand.RowCount });
        }
    }
}
